package com.yyz.zjjcms.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

/**
 * RootUrl entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "root_url", catalog = "zjjcms")
public class RootUrl implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 3845586416696952326L;
	private String id;
	private String name;
	private String pid;
	private Integer number;
	private Set<Role> roles = new HashSet<Role>(0);

	// Constructors

	/** default constructor */
	public RootUrl() {
	}

	/** minimal constructor */
	public RootUrl(String id) {
		this.id = id;
	}

	/** full constructor */
	public RootUrl(String id, String name, String pid, Integer number,
			Set<Role> roles) {
		this.id = id;
		this.name = name;
		this.pid = pid;
		this.number = number;
		this.roles = roles;
	}

	// Property accessors
	@Id
	@Column(name = "Id", nullable = false, length = 36)
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "org.hibernate.id.UUIDGenerator")
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "name")
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "p_id")
	public String getPid() {
		return this.pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}

	@Column(name = "number")
	public Integer getNumber() {
		return this.number;
	}

	public void setNumber(Integer number) {
		this.number = number;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "role_has_root_url", catalog = "zjjcms", joinColumns = { @JoinColumn(name = "root_url_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "role_id", nullable = false, updatable = false) })
	public Set<Role> getRoles() {
		return this.roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

}